# 例3：While 条件终止循环
from turtle import *
color('red', 'green')
begin_fill()
count = 0  # 添加循环次数计数器
max_count = 1000  # 设置最大循环次数
while True:
    forward(200)
    left(170)
    if abs(pos()) < 1 or count > max_count:  # 添加循环次数检查条件
        break
    count += 1  # 每次循环增加计数器
end_fill()
done()